/**
 * Created by free on 2017/7/8.
 */

//////////////////////////////功能
//删除学生
function delStudent (student_id) {
    var boo=confirm("确定删除？");
    if (boo){
        $.get("/StudentServlet?action=delStudent&student_id="+student_id,function (data) {
            var message=$(data).find("message").text();
            alert(message);
            location.reload();
        });
    }
}
//得到学生详情
function studentDetail(student_id) {
    open("/StudentServlet?action=getStudentDetail&student_id="+student_id, "_self");
}
//数据导出excel
function exportExcel(exported) {
    open("/StudentServlet?action=exportExcel&exported="+exported,"_self");
}

////////////////////////分页
//得到班级某页的数据
function getStudentData(url) {
    $.ajax({
        type:"post",
        url:url,
        dataType:"json",
        success:function (data) {
            $("#studentList_body").html("");
            $("#studentList_head").html("");
            $("#studentList_head").append("<tr> <th>学号</th> <th>姓名</th> <th>性别</th> <th>状态</th> <th>QQ</th> <th>操作</th> </tr>");
            for(var i in data){
                $("#studentList_body").append("<tr><td>"+data[i].student_id+"</td><td>"+data[i].student_name+"</td><td>"+data[i].student_sex+"</td><td>"+data[i].student_state+"</td><td>"+data[i].student_qq+"</td><td><div class='btn-group  btn-group-xs' ><button class='btn btn-default btn-warning' onclick='delStudent(\""+data[i].student_id+"\")'>删除</button><button class='btn btn-default btn-info' onclick='studentDetail(\""+data[i].student_id+"\")'>详情</button></div></td></tr>");

            }
        },
    });
}

//获取总页数
function getPageSum(url) {
    $.ajax({
        async:false,
        type:"get",
        url:url,
        dataType:"text",
        success:function (data) {
            pageSum= data;
        }
    });
}
